#默认参数要放在最后边
def greet(name, age=18):
    print(f"Hello, {name}! You are {age} years old.")
greet("Alice")  # 使用默认参数
greet("Bob", 25)  # 使用自定义参数
#可变参数,要放在最后边
# 可变参数允许函数接受任意数量的位置参数
def add_numbers(*args):
    total = 0
    for num in args:
        total += num
    return total
print(add_numbers(1, 2, 3))  # 输出: 6
print(add_numbers(1, 2, 3, 4, 5))  # 输出: 15
# def print_info(name, *args):
#     print(f"Name: {name}")
#     print("Other info:")
#     for arg in args:
#         print(arg)
# print_info("Alice", 25, "Engineer", "New York")  
# 关键字参数允许函数接受任意数量的命名参数 ，字典
def print_info(**kwargs):
    print(kwargs,type(kwargs)) 
print_info(age=25, job="Engineer", city="New York")
#*sorce:对元组数据进行解包；**sorce:对字典数据进行解包
sorce=[1,5,55,4,5,47,4,745,]  
def print_scores(*ars):
    return sum(ars)/len(ars)
print(print_scores(*sorce))

